<?php
ob_start();
@include('include/common.inc.php');
/**************浏览的cookie*******************/
$Cookie_7 = $_COOKIE['Cookie_7_Id'];
if(empty($Cookie_7))
{
	$Cookie_7= 0;
}else{
	$cookie7 = explode(',',$Cookie_7);
	$count7 = count($cookie7);
	if($count7>2)
	{
			$Cookie_7 = $cookie7[0].','.$cookie7[1].','.$cookie7[2];
	}elseif($count7==2){
			$Cookie_7 = $cookie7[0].','.$cookie7[1];
	}elseif($count7==1){
			$Cookie_7 = $cookie7[0];
	}

	if($cookie7[0]!='')
	{
		$sql_Cookie_7 = "select * from $TBL_HOUSE where id in($cookie7[0]) and id !='' limit 1";
		$res_Cookie_7 =$db->query($sql_Cookie_7);
		while($rows = $db->fetch_array($res_Cookie_7))
		{
			$rows['7_name'] = FSubstr(str_replace("&nbsp;","",strip_tags($rows['title'])),0,28);
			$row_Cookie_7[]=$rows;
		}
	}
	if($cookie7[1]!='')
	{
		$sql_Cookie_72 = "select * from $TBL_HOUSE where id in($cookie7[1]) and id !='' limit 1";
		$res_Cookie_72 =$db->query($sql_Cookie_72);
		while($rows = $db->fetch_array($res_Cookie_72))
		{
			$rows['7_name'] = FSubstr(str_replace("&nbsp;","",strip_tags($rows['title'])),0,28);
			$row_Cookie_72[]=$rows;
		}
	}
	if($cookie7[2]!='')
	{
		$sql_Cookie_73 = "select * from $TBL_HOUSE where id in($cookie7[2]) and id !='' limit 1";
		$res_Cookie_73 =$db->query($sql_Cookie_73);
		while($rows = $db->fetch_array($res_Cookie_73))
		{
			$rows['7_name'] = FSubstr(str_replace("&nbsp;","",strip_tags($rows['title'])),0,28);
			$row_Cookie_73[]=$rows;
		}
	}
}
/*********************************/

/************Search的cookie*********************/
$i=-1;
$Cookie_5x = $_COOKIE['Cookie5'];
$time = date("Y-m-d",time()-86400*5);
$sql_Cookie555 = "select * from $TBL_CACHE  where cookie_id='$Cookie_5x' and c_time>='$time' order by id desc limit 5";
$res_Cookie555 =$db->query($sql_Cookie555);
$nums =mysql_num_rows($res_Cookie555);
while($rows = $db->fetch_array($res_Cookie555))
{
	++$i;
	$sel51 = "select * from $TBL_HOU_CATE where cate_id =".$rows['p_id'];
	$res51 =$db->query($sel51);
	$rows51 = $db->fetch_array($res51);
	$show51 = ' - '.$rows51['zh_cate_title'];

	$sel52 = "select * from $TBL_HOU_CATE where cate_id =".$rows['c_id'];
	$res52 =$db->query($sel52);
	$rows52 = $db->fetch_array($res52);
	$show52 = $rows52['zh_cate_title'];

	$row_Cookie_5[$i] = $show52.$show51.' - '.$rows['t_id']."&nbsp;&nbsp;&nbsp;<a href='search.php?city=".$rows['c_id']."&pro=".$rows['p_id']."&typex=".$rows['t_id']."'>顯示搜索</a>";
	$show51 = ''; $show52='';
}
if($nums==0)
{
	$Cookie_5 = 1;
}
/*********************************/

$sel4 = "select * from $TBL_HOU_CATE where parent_id=0 order by cate_order asc";   //区域导航
$res4 =$db->query($sel4);
while($rows = $db->fetch_array($res4))
{
	$row4[]=$rows;
}

//生活简约型

$sel_jy = "select * from $TBL_HOUSE where saveplan=1 and del=0  order by id desc limit 0,3";
$res_jy = mysql_query($sel_jy);
while($row = @mysql_fetch_array($res_jy))
{
	$row['jy_name'] = FSubstr(str_replace("&nbsp;","",strip_tags($row['title'])),0,28);
	$row_jy[] = $row;
}

//高雅型

$sel_gy = "select * from $TBL_HOUSE where saveplan=2 and del=0 order by id desc limit 0,3";
$res_gy = mysql_query($sel_gy);
while($row = @mysql_fetch_array($res_gy))
{
	$row['gy_name'] = FSubstr(str_replace("&nbsp;","",strip_tags($row['title'])),0,28);
	$row_gy[] = $row;
}
//尊贵型

$sel_zg = "select * from $TBL_HOUSE where saveplan=3 and del=0 order by id desc limit 0,3";
$res_zg = mysql_query($sel_zg);
while($row = @mysql_fetch_array($res_zg))
{
	$row['zg_name'] = FSubstr(str_replace("&nbsp;","",strip_tags($row['title'])),0,28);
	$row_zg[] = $row;
}

//宅速配
$sel_zsp = "select * from $TBL_HOUSE where del=0 order by id desc limit 0,5";
$res_zsp = mysql_query($sel_zsp);
while($row = @mysql_fetch_array($res_zsp))
{
	$row["sale_title"] = FSubstr(str_replace("&nbsp;","",strip_tags($row['title'])),0,20);
	$rowzsp[] = $row;
}


//sale
$sel_sale = "select * from $TBL_HOUSE where feature=1 and hou_type=2 and del=0 order by id desc limit 0,5";
$res_sale = mysql_query($sel_sale);
while($row = @mysql_fetch_array($res_sale))
{
	$row["sale_title"] = FSubstr(str_replace("&nbsp;","",strip_tags($row['title'])),0,20);
	$rowsale[] = $row;
}



//站长推荐
$sel = "select * from $TBL_HOUSE where recommended=1 and del=0 order by id desc limit 0,4";
$res = mysql_query($sel);
while($row = @mysql_fetch_array($res))
{
	$row['adminshowz']=FSubstr(str_replace("&nbsp;","",strip_tags($row['adminshow'])),0,95);
	$rowrec[] = $row;
}

//本日精选
$sel2 = "select * from $TBL_HOUSE where del=0 order by add_time desc limit 0,15";
$res2 = mysql_query($sel2);
while($row = @mysql_fetch_array($res2))
{
	$row['TIT'] = FSubstr(str_replace("&nbsp;","",strip_tags($row['title'])),0,26);
	$rowday[] = $row;
}

//房產新聞
$fanchang = "select * from $TBL_NEWS0 where cate_id=18 order by id desc limit 0,1";
$res_fc = mysql_query($fanchang);
$row_fc = @mysql_fetch_array($res_fc);


//家具生活
$jiaju = "select * from $TBL_NEWS0 where cate_id=19 order by id desc limit 0,1";
$res_jj = mysql_query($jiaju);
$row_jj = @mysql_fetch_array($res_jj);


//广告
$seladv = "select * from $TBL_ADV order by id asc";
$resadv = mysql_query($seladv);
while($row = @mysql_fetch_array($resadv))
{
	$rowadv[] = $row;
}

$selaa = "select * from $TBL_OPTION where type=1 order by ord asc";//類型
$resaa = mysql_query($selaa);
while($rowaa = @mysql_fetch_array($resaa))
{
   $typeaa = $typeaa ."<OPTION value=$rowaa[title]>".$rowaa[title]."</OPTION>";
}

$selwl = "select * from $TBL_OPTION where type=12 order by ord asc";//ps
$reswl = mysql_query($selwl);
while($rowwl = @mysql_fetch_array($reswl))
{
   $typewl = $typewl ."<OPTION value=$rowwl[title]>".$rowwl[title]."</OPTION>";
}

$selps = "select * from $TBL_OPTION where type=11 order by ord asc";//ps
$resps = mysql_query($selps);
while($rowps = @mysql_fetch_array($resps))
{
   $typeps = $typeps ."<OPTION value=$rowps[title]>".$rowps[title]."</OPTION>";
}

/*分店選項 thrfou add*/
$selStore = "select * from $TBL_STORE";
$resStore = mysql_query($selStore);
while($rowStore = @mysql_fetch_array($resStore))
{
   $typeStore = $typeStore ."<OPTION value=$rowStore[id]>".$rowStore[name]."</OPTION>";
}

$selgj = "select * from $TBL_OPTION where type=13 order by ord asc";//格 &nbsp; 局：
$resgj = mysql_query($selgj);
while($rowgj = @mysql_fetch_array($resgj))
{
   $typegj = $typegj ."<OPTION value=$rowgj[title]>".$rowgj[title]."</OPTION>";
}

//jy
$smarty->assign("row_jy",$row_jy);
//GY
$smarty->assign("row_gy",$row_gy);
//zg
$smarty->assign("row_zg",$row_zg);


$smarty->assign("rowz1",$rowz1);
$smarty->assign("rowz2",$rowz2);
$smarty->assign("rowz3",$rowz3);
$smarty->assign("rowz4",$rowz4);

//sale

$smarty->assign("rowsale",$rowsale);

$smarty->assign("rowrec",$rowrec);
$smarty->assign("rowday",$rowday);

$smarty->assign("rowcj",$rowcj);
$smarty->assign("rowcj2",$rowcj2);
$smarty->assign("rowcj3",$rowcj3);

$smarty->assign("rowadv",$rowadv);
$smarty->assign("row4",$row4);

$smarty->assign("typeaa",$typeaa);
$smarty->assign("typeps",$typeps);
$smarty->assign("typeStore",$typeStore);//分店 thrfou
$smarty->assign("typegj",$typegj);
$smarty->assign("typewl",$typewl);
$smarty->assign("mem_id",$_SESSION['mem_id']);
$smarty->assign("type",$_SESSION['type']);

//房產新聞
$smarty->assign("fc_title",$row_fc['ch_headline']);
$smarty->assign("fc_addtime",FSubstr($row_fc['date_added'],0,11));
$smarty->assign("fc_img",$row_fc['img']);
$smarty->assign("fc_text",FSubstr(str_replace("&nbsp;","",strip_tags($row_fc['ch_text'])),0,260));
$smarty->assign("fc_id",$row_fc['id']);
$smarty->assign("fc_cate_id",$row_fc['cate_id']);

//家具生活
$smarty->assign("jj_title",$row_jj['ch_headline']);
$smarty->assign("jj_addtime",FSubstr($row_jj['date_added'],0,11));
$smarty->assign("jj_img",$row_jj['img']);
$smarty->assign("jj_text",FSubstr(str_replace("&nbsp;","",strip_tags($row_jj['ch_text'])),0,260));
$smarty->assign("jj_id",$row_jj['id']);
$smarty->assign("jj_cate_id",$row_jj['cate_id']);

//宅速配
$smarty->assign("rowzsp",$rowzsp);
$smarty->assign("mem_id",$_SESSION['mem_id']);

//cookie
$smarty->assign("row_Cookie_5",$row_Cookie_5);
$smarty->assign("row_Cookie_7",$row_Cookie_7);
$smarty->assign("row_Cookie_72",$row_Cookie_72);
$smarty->assign("row_Cookie_73",$row_Cookie_73);

$smarty->assign("show_7",$show_7);
$smarty->assign("show_5",$show_5);
$smarty->assign("Cookie_5",$Cookie_5);
$smarty->assign("Cookie_7",$Cookie_7);

@include('number.php');//验证码
$smarty->display('index.html');
?>